#include "item.h"

#include <time.h>

Item::~Item()
{
	
}

Item::Item() :
	Sprite(Vector2f(), Vector2f(), "item"),
	gdata( Gamedata::getInstance() )
{
	int width = gdata.getXmlInt("worldWidth"); 
	int height = gdata.getXmlInt("worldHeight");
	int itemWidth = gdata.getXmlInt("itemWidth");
	int itemHeight = gdata.getXmlInt("itemHeight");
	const int minSpeedX = gdata.getXmlInt("itemXspeedMin");
	const int maxSpeedX = gdata.getXmlInt("itemXspeedMax");
	const int minSpeedY = gdata.getXmlInt("itemYspeedMin");
	const int maxSpeedY = gdata.getXmlInt("itemYspeedMax");

	int x = rand()% (width-itemWidth) + itemWidth/2;
	int y = rand()% (height-itemWidth) + itemHeight/2;
	int sx = (rand() % (maxSpeedX-minSpeedX)) + minSpeedX;
	int sy = (rand() % (maxSpeedY-minSpeedY)) + minSpeedY;
	sx = x - sx*(1.0/30.0)*(rand()%2?1:-1);
	sy = y - sy*(1.0/30.0)*(rand()%2?1:-1);

	setPosition(Vector2f(x, y));
	//setVelocity(Vector2f(sx,sy));
}

void Item::update()
{
	
}
